import { _decorator, Component, Node, RigidBody, Vec2 } from 'cc';
import { StateDefine } from '../../Config';
import { PlayerGroundState } from './PlayerGroundState';
const { ccclass, property } = _decorator;

@ccclass('PlayerMoveState')
export class PlayerMoveState extends PlayerGroundState {
    onEnter(): void {
        super.onEnter();
    }
    update(deltaTime: number) {
        super.update(deltaTime);
        this.player.setVelocity(this.player.MoveSpeed*this.player.input.x,this.rb.linearVelocity.y)
        if(this.player.input.x == 0&&!this.player.isBusy){
            this.player.stateMgr.transit(StateDefine.Idle);
        }
    }
    onExit(): void {
        super.onExit();
    }
    onDestory(): void {}
    canTransit(to: StateDefine): boolean {
        if (to == StateDefine.Run) {
            return false;
        }
        return true;
    }
}


